var top = require("top");
var smsVariables = require("../../config/variables").sms;

var client = top.createClient({
    appkey: smsVariables.appkey,
    appsecret: smsVariables.appsecret,
    REST_URL: smsVariables.url
});

// 发送短信
module.exports = {
  // 发送验证码
  sendVCode: function(mobile, vcode) {
    var params = {
        extend: "",
        sms_type: "normal",
        sms_free_sign_name: "注册验证",
        sms_param: '{"product":【好就投】,"code":"' + vcode + '"}',
        rec_num: mobile,
        sms_template_code: smsVariables.templateCode.vcode
    };
    client.invoke('alibaba.aliqin.fc.sms.num.send', params, [], null, 'GET', function (err, result) {
      if (err) {
        // 发送失败
        console.log("发送短信失败.err=%s", err);
        throw err;
      }
      // 发送成功
      console.log("短信发送成功.");
    });
  }
}
